package com.daxue.activitibase;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.Before;
import org.junit.Test;

/**
 * @author daxue0929
 * @date 2023/2/23
 */

public class ActivitiDemo {

    private ProcessEngine processEngine;

    @Before
    public void init() {
        ProcessEngineConfiguration processEngineConfigurationFromResource =
            ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
        processEngine = processEngineConfigurationFromResource.buildProcessEngine();
    }

    @Test
    public void testDeployment() {
        RepositoryService repositoryService = processEngine.getRepositoryService();

        Deployment deploy = repositoryService.createDeployment()
            .name("出差申请流程")
            .addClasspathResource("bpmn/test.bpmn20.xml")
            .addClasspathResource("bpmn/test.bpmn.png")
            .deploy();
        //输出部署的信息
        System.out.println("部署的id: "+ deploy.getId());
        System.out.println("部署的name: "+ deploy.getName());

    }
}
